/*
 * main.cpp
 *
 *  Created on: 04.03.2012
 *      Author: Lenin
 *
 *Car  Hours  Charge
 *  1    1.5     2.0
 *  2    4.0     2.5
 *  3   24.0    10.0
 *TOTAL 29.5    14.5
 */
#include <iostream>
#include <iomanip>
using namespace std;

void charge(double, double &, double &);

static double sumHour= 0;
static double sumCharge = 0;

int main(int argc, const char* argv[] ){

	cout<< setw(3)<< "Car "<< setw(5) << " Hours " << setw(5) << " Charge " <<endl;

	charge(1.5, sumHour, sumCharge);
	charge(4, sumHour, sumCharge);
	charge(24, sumHour, sumCharge);

	cout<<setw(3) <<"TOTAL" << setw(5) << sumHour << setw(8) << sumCharge <<endl;
}

void charge(double hour,double &sumHour, double &sumCharge){
	static int i=0;
	double charge=0;

	if ( hour <= 3 )
	{
		charge = 2;
		cout <<setw(3) <<++i <<setw(7) <<hour <<setw(8) <<fixed <<setprecision(1) <<charge <<endl;
	}
	else
		if (hour > 3 && hour < 24)
		{
		charge=((hour - 3) * 0.5) + 2;
		cout <<setw(3) <<++i <<setw(7) <<fixed <<setprecision(1) <<hour <<setw(8) <<charge <<endl;
		}
		else
			{
			charge = 10;
			cout <<setw(3) <<++i <<setw(7) <<hour <<setw(8) <<charge <<endl;
			}

	sumCharge += charge;
	sumHour += hour;
}
